#ifndef NODE_H
#define NODE_H

#include "EngineApi.h"
#include "Mesh.h"
#include "BoundingBox.h"

#include <vector>

class ENGINE_API Node : public Entity
{
public:
   Node(const std::string& name);
   void addChild(Node* child);
   void removeChild(Node* child);
   void addMesh(Mesh* mesh);

   void setTransform(Matrix transform) { m_importedMatrix = transform; }

   virtual void draw(Renderer* renderer);

   Node* getNodeByName(std::string name);

private:
   std::vector<Node*> m_childdren;
   std::vector<Mesh*> m_meshes;

   Matrix m_globalMatrix;
   //Matrix m_localMatrix;
   Matrix m_importedMatrix;

   BoundingBox* m_boundingBox;

   void preDraw(Matrix transform, Renderer* renderer);
   void drawMeshes(Renderer* renderer);

   void createBoundingBoxes();
   void compareMaxMinVectors(const Vector3 &max1, const Vector3 &min1, Vector3 &max2, Vector3 &min2);

   void recursiveSerchChild(std::string name, Node** node);
};
#endif//NODE_H